#!/usr/bin/make -f

build: clean
	mkdir debian/build
	cd debian/build && cmake -D CMAKE_BUILD_TYPE=relwithdebuginfo ../..
	cd debian/build && $(MAKE)

clean:
	rm -rf debian/files debian/substvars debian/tmp debian/build

binary: binary-arch binary-indep

binary-indep:

binary-arch: build
	rm -rf debian/tmp
	install -d debian/tmp/DEBIAN
	install -d debian/tmp/usr/include/dashel
	install -d debian/tmp/usr/lib
	install -d debian/tmp/usr/share/doc/libdashel
	strip --strip-unneeded -R .note -R .comment debian/build/libdashel.a
	cp changelog debian/tmp/usr/share/doc/libdashel/changelog
	cp debian/changelog debian/tmp/usr/share/doc/libdashel/changelog.debian
	cp debian/copyright debian/tmp/usr/share/doc/libdashel
	cp dashel/dashel.h debian/tmp/usr/include/dashel
	cp debian/build/libdashel.a debian/tmp/usr/lib
	chown -R root.root debian/tmp
	chmod -R o-s,go=u,go-ws debian/tmp
	dpkg-gencontrol
	dpkg --build debian/tmp ..
